﻿using AppMachine.Domain;
using AppMachine.Domain.Entities;

namespace AppMachine.Domain.LogicCom;

/// <summary>
/// 应用逻辑组件配置
/// </summary>
public class AppComConfig : IComConfig, IHasAutoIncreasingID {

    private IComConfigRepository mfComConfigRepository = null;
    public AppComConfig SetRepository(IComConfigRepository comConfigRepository) { 
        this.mfComConfigRepository= comConfigRepository;
        return this;
    }
    public AppComConfig Save() {
        this.mfComConfigRepository?.InsertOrUpdate(this);
        return this;
    }

    public long AutoID { get; set; }
    /// <summary>
    /// 应用组件ID
    /// </summary>
    public string ComID { get; set; }
    /// <summary>
    ///  应用组件父级组件ID
    /// </summary>
    public string? OwnID { get; set; }
    /// <summary>
    /// 应用组件应用名称
    /// </summary>
    public string? ComName { get; set; }
    /// <summary>
    /// 应用组件标签名称
    /// </summary>
    public string? TagName { get; set; }
    /// <summary>
    /// 应用组件应用描述
    /// </summary>
    public string? ComDesc { get; set; }
    /// <summary>
    /// 应用组件应用序号
    /// </summary>
    public int ComIndex { get; set; }
    /// <summary>
    /// 应用组件服务类型
    /// </summary>
    public string ComType { get; set; }
    /// <summary>
    /// 应用组件对象的构造参数(序列化值，默认为yaml)
    /// </summary>
    public string? ComParamSerialized { get; set; }
    /// <summary>
    /// 应用组件对应的外设ID(该属性暂时仅针对原子组件 DI,DO,伺服)
    /// </summary>
    public string? PerpDevID { get; set; }
    /// <summary>
    /// 应用组件对应的外设点位ID(该属性暂时仅针对原子组件 DI,DO,伺服)
    /// </summary>
    public string? PerpSeatID { get; set; }
}

public interface IComConfig {
    /// <summary>
    /// 应用组件ID
    /// </summary>
    string ComID { get; }
    /// <summary>
    ///  应用组件父级组件ID
    /// </summary>
    string? OwnID { get; }
    /// <summary>
    /// 应用组件应用名称
    /// </summary>
    string? ComName { get; }
    /// <summary>
    /// 应用组件标签名称
    /// </summary>
    string? TagName { get; }
    /// <summary>
    /// 应用组件应用描述
    /// </summary>
    string? ComDesc { get; }
    /// <summary>
    /// 应用组件应用序号
    /// </summary>
    int ComIndex { get; }
    /// <summary>
    /// 应用组件对象类型
    /// </summary>
    string ComType { get; }
    /// <summary>
    /// 应用组件对象的构造参数(序列化值，默认为yaml)
    /// </summary>
    string ComParamSerialized { get; }
    /// <summary>
    /// 应用组件对应的外设ID(该属性暂时仅针对原子组件 DI,DO,伺服)
    /// </summary>
    string? PerpDevID { get; }
    /// <summary>
    /// 应用组件对应的外设点位ID(该属性暂时仅针对原子组件 DI,DO,伺服)
    /// </summary>
    string? PerpSeatID { get; }
}